package com.example.mylibrarybase.yumengmeng24.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.mylibrarybase.R;
import com.example.mylibrarybase.bar.initAction_Bar;
import com.example.mylibrarybase.base.baseViewPager.BaseViewPagerAdapter;
import com.example.mylibrarybase.base.baseui.BaseActivity;
import com.example.mylibrarybase.view.MyViewPager;
import com.example.mylibrarybase.view.NoScroolListView;
import com.example.mylibrarybase.yumengmeng01.adapter.ImageAdapter;
import com.example.mylibrarybase.yumengmeng01.bean.Banner;
import com.example.mylibrarybase.yumengmeng04.base.BaseListViewAdapter_04;
import com.example.mylibrarybase.yumengmeng24.adapter.fenfaAdapter;
import com.example.mylibrarybase.yumengmeng24.base.itemss;
import com.jingchen.pulltorefresh.PullToRefreshLayout;
import com.jingchen.pulltorefresh.pullableview.PullableScrollView;

import java.util.ArrayList;

public class MainActivity_shijianfenfa_24 extends BaseActivity {

    private initAction_Bar mBase_action_bar;
    private NoScroolListView mFenfa_listview;
    private PullToRefreshLayout mRefresh_view;
    private MyViewPager mFenfa_viewpager;
    private PullableScrollView mFenfa_scrollView;
    private RelativeLayout mRr;
    private RelativeLayout mHeaderView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    public int getlayouXML() {
        return R.layout.activity_main_shijianfenfa_24;
    }

    @Override
    public void initView() {
        mBase_action_bar = (initAction_Bar) findViewById(R.id.base_action_bar);
        mBase_action_bar.setCallBack(new initAction_Bar.Action_bar_call_back() {
            @Override
            public void getAction_barView_backbutton(TextView textView) {

            }

            @Override
            public void getAction_barView_backbutton_icon(ImageView imageView) {

            }

            @Override
            public void getAction_barView_title(TextView textView) {
                textView.setText("事件分发");
            }

            @Override
            public void getAction_barView_right_icon(ImageView imageView) {
            }
        });
      //  mFenfa_scrollView = (PullableScrollView) findViewById(R.id.fenfa_ScrollView);

        mFenfa_listview = (NoScroolListView) findViewById(R.id.fenfa_listview);
       // mRefresh_view = (PullToRefreshLayout) findViewById(R.id.refresh_view);
        LayoutInflater lif = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mHeaderView = (RelativeLayout)lif.inflate(R.layout.item_24_viewpager, mFenfa_listview,false);
       // RelativeLayout inflate = (RelativeLayout)View.inflate(this, R.layout.item_24_viewpager, null);
        mFenfa_viewpager = (MyViewPager) mHeaderView.findViewById(R.id.fenfa_viewpager);


      /*  mRefresh_view.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh(final PullToRefreshLayout pullToRefreshLayout) {
                // 下拉刷新操作
                new Handler()
                {
                    @Override
                    public void handleMessage(Message msg)
                    {
                        // 千万别忘了告诉控件刷新完毕了哦！
                        pullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
                    }
                }.sendEmptyMessageDelayed(0, 2000);
            }

            @Override
            public void onLoadMore(final PullToRefreshLayout pullToRefreshLayout) {
                // 下拉刷新操作
                new Handler()
                {
                    @Override
                    public void handleMessage(Message msg)
                    {
                        // 千万别忘了告诉控件刷新完毕了哦！
                        pullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
                    }
                }.sendEmptyMessageDelayed(0, 2000);
            }
        });*/
//        if (null!=mFenfa_viewpager){
//            InterceptorFrame interceptorFrame = new InterceptorFrame(this);
//            interceptorFrame.addInterceptorView(mFenfa_viewpager.getRootView(),InterceptorFrame.ORIENTATION_LEFT|InterceptorFrame.ORIENTATION_RIGHT);
//            mRr.removeView(mFenfa_listview);
//            interceptorFrame.addView(mFenfa_listview);
//
//        }
        initData();
    }

    @Override
    public void initData() {
        ArrayList<itemss> itemsses = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            itemsses.add(new itemss("事件分发",i+""));
        }

        fenfaAdapter fenfaAdapter = new fenfaAdapter(this, 0, itemsses, new BaseListViewAdapter_04.CallBack() {
            @Override
            public void loadMore(View view, int position, int type) {

            }
        });

        mFenfa_listview.setAdapter(fenfaAdapter);
        ArrayList<Banner> banners = new ArrayList<>();
        banners.add(new Banner("http://pic.yesky.com/uploadImages/2015/026/38/MG734XC8AM7T.jpg"));
        banners.add(new Banner("http://www.gamemei.com/background/uploads/160829/30-160R9143H3343.jpg"));
        banners.add(new Banner("http://www.gamemei.com/background/uploads/160829/30-160R9143612P5.jpg"));
        banners.add(new Banner("http://img3.duitang.com/uploads/item/201608/20/20160820091508_diTXf.thumb.700_0.jpeg"));
        banners.add(new Banner("http://joymepic.joyme.com/article/uploads/allimg/201609/1473906749455425.jpg?watermark/1/image/aHR0cDovL2pveW1lcGljLmpveW1lLmNvbS9hcnRpY2xlL3VwbG9hZHMvMTYwODE5LzgwLTE2MFE5MUZaMzQzOC5wbmc=/dissolve/70"));
        ImageAdapter imageAdapter = new ImageAdapter(this, banners, new BaseViewPagerAdapter.CallBack() {
            @Override
            public void onItemPos(int pos) {

            }
        });
        mFenfa_viewpager.setAdapter(imageAdapter);
        AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.dp_200));
        mFenfa_viewpager.setLayoutParams(layoutParams);
        mFenfa_listview.addHeaderView(mFenfa_viewpager);
    }
}
